package com.ustc.phoenix.dao;

import com.ustc.phoenix.models.TestPojo;

import java.sql.*;


public class TestDAO {
	Statement stmt=null;
	ResultSet rs=null;

	TestPojo test=new TestPojo();
	public void initDriver(){
		try{
			/**
			 * Init JDBC Driver
			 */
			Class.forName("com.mysql.jdbc.Driver").newInstance();
			//Create connenction
			Connection conn= DriverManager.getConnection("jdbc:mysql://localhost/lucene?"+
			"user=chenna$password=chenna");
			stmt=conn.createStatement();
			rs = stmt.executeQuery("Select foo from bar");

		}catch (SQLException e){
			System.out.println("SQLException:"+e.getMessage());
			System.out.println("SQLState:"+e.getSQLState());
			System.out.print("VendorError:"+e.getErrorCode());
		}catch (Exception e){

		}finally {
			// it is a good idea to release
			// resources in a finally{} block
			// in reverse-order of their creation
			// if they are no-longer needed
			if(rs!=null){
				try{
					rs.close();
				}catch (SQLException e){

				}
				rs=null;
			}
			if(stmt!=null){
				try {
				stmt.close();
				}catch (SQLException e){}
				stmt=null;
			}
		}

	}
}
